package com.cm.stock.manager.ui;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Rectangle;

import javax.swing.JFrame;
import java.awt.Toolkit;
import java.awt.Color;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.SwingConstants;
import javax.swing.JButton;

import com.cm.stock.manager.utils.CMStockManagerUtils;

import java.awt.SystemColor;
import java.util.Calendar;

public class MAinWindow  extends JFrame {

	
	int width = 1200;
	int height = 1000;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MAinWindow window = new MAinWindow();
					window.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public MAinWindow() {
		getContentPane().setBackground(Color.WHITE);
		
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.home.png")));
		setTitle("Stock Manager");
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int width = (int) screenSize.getWidth();
		int height = (int) screenSize.getHeight();
		setSize( width	, height);
		setLocationRelativeTo(null);
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		getContentPane().setBounds(new Rectangle(0, 0, width, height));
		getContentPane().setLayout(null);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBounds(0, 0, width, 30);
		getContentPane().add(menuBar);
		
		JMenu mnFichier = new JMenu("Fichier");
		mnFichier.setMnemonic('f');
		menuBar.add(mnFichier);
		
		JMenuItem mntmAccueil = new JMenuItem("Accueil");		
		mntmAccueil.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		mnFichier.add(mntmAccueil);
		
		JPanel headerPanel = new JPanel();
		headerPanel.setLayout(null);
		headerPanel.setBorder(new MatteBorder(1, 0, 1, 0, (Color) new Color(0, 0, 0)));
		headerPanel.setBackground(Color.WHITE);
		int centerX = (width - 800)/2;
		headerPanel.setBounds(centerX, 50, 800, 100);
		
		//panel.setlo(null);
		getContentPane().add(headerPanel);
		
		JLabel lblNomDeLentreprise = new JLabel(CMStockManagerUtils.CURRENT_USER.getPointVente().getName());
		lblNomDeLentreprise.setFont(new Font("Segoe UI", Font.BOLD, 18));
		lblNomDeLentreprise.setBounds(10, 11, 343, 29);
		headerPanel.add(lblNomDeLentreprise);
		
		JLabel lblStockManager = new JLabel("Stock Manager");
		lblStockManager.setFont(new Font("Segoe UI Light", Font.PLAIN, 16));
		lblStockManager.setBounds(10, 60, 343, 30);
		headerPanel.add(lblStockManager);
		
		JLabel lblNewLabel = new JLabel(CMStockManagerUtils.CURRENT_USER.getPointVente().getDescription());
		lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		lblNewLabel.setFont(new Font("Segoe UI", Font.BOLD, 18));
		lblNewLabel.setBounds(570, 11, 220, 30);
		headerPanel.add(lblNewLabel);
		
		JLabel lblAnnee = new JLabel(Calendar.getInstance().get(Calendar.YEAR)+"");
		lblAnnee.setFont(new Font("Segoe UI Light", Font.PLAIN, 16));
		lblAnnee.setHorizontalAlignment(SwingConstants.RIGHT);
		lblAnnee.setBounds(687, 60, 103, 30);
		headerPanel.add(lblAnnee);
		
		JPanel contentPanel = new JPanel();
		contentPanel.setBackground(Color.WHITE);
		contentPanel.setLayout(null);
		contentPanel.setBounds(centerX, 161, 800, 400);
		getContentPane().add(contentPanel);
		
		JButton btnArticle = new JButton("Article");
		btnArticle.setHorizontalAlignment(SwingConstants.LEFT);
		btnArticle.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.box.layered.png")));
		btnArticle.setMnemonic('a');
		btnArticle.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnArticle.setForeground(Color.BLACK);
		btnArticle.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnArticle.setBackground(Color.WHITE);
		btnArticle.setBounds(10, 38, 220, 60);
		contentPanel.add(btnArticle);
		
		JButton btnFamilleDarticle = new JButton("Famille d'article");
		btnFamilleDarticle.setMnemonic('m');
		btnFamilleDarticle.setHorizontalAlignment(SwingConstants.LEFT);
		btnFamilleDarticle.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.layer.thick.png")));
		btnFamilleDarticle.setForeground(Color.BLACK);
		btnFamilleDarticle.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnFamilleDarticle.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnFamilleDarticle.setBackground(Color.WHITE);
		btnFamilleDarticle.setBounds(10, 269, 220, 60);
		contentPanel.add(btnFamilleDarticle);
		
		JButton btnGroupeDarticle = new JButton("Groupe d'article");
		btnGroupeDarticle.setMnemonic('g');
		btnGroupeDarticle.setHorizontalAlignment(SwingConstants.LEFT);
		btnGroupeDarticle.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.layer.png")));
		btnGroupeDarticle.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnGroupeDarticle.setForeground(Color.BLACK);
		btnGroupeDarticle.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnGroupeDarticle.setBackground(Color.WHITE);
		btnGroupeDarticle.setBounds(10, 144, 220, 60);
		contentPanel.add(btnGroupeDarticle);
		
		JButton btnVentes = new JButton("R\u00E9ception");
		btnVentes.setMnemonic('r');
		btnVentes.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.cart.png")));
		btnVentes.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new ReceptionUI(MAinWindow.this);
			}
		});
		btnVentes.setHorizontalAlignment(SwingConstants.LEFT);
		btnVentes.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnVentes.setBackground(Color.WHITE);
		btnVentes.setBounds(292, 38, 220, 60);
		contentPanel.add(btnVentes);
		
		JButton btnEncaissement = new JButton("Encaissement");
		btnEncaissement.setMnemonic('e');
		btnEncaissement.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnEncaissement.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.currency.cent.png")));
		btnEncaissement.setHorizontalAlignment(SwingConstants.LEFT);
		btnEncaissement.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnEncaissement.setBackground(Color.WHITE);
		btnEncaissement.setBounds(292, 144, 220, 60);
		contentPanel.add(btnEncaissement);
		
		JButton btnLivraison = new JButton("Livraison");
		btnLivraison.setMnemonic('l');
		btnLivraison.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnLivraison.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.transit.car.png")));
		btnLivraison.setHorizontalAlignment(SwingConstants.LEFT);
		btnLivraison.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnLivraison.setBackground(Color.WHITE);
		btnLivraison.setBounds(292, 269, 220, 60);
		contentPanel.add(btnLivraison);
		
		JButton btnHistorique = new JButton("Historique");
		btnHistorique.setMnemonic('h');
		btnHistorique.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnHistorique.setHorizontalAlignment(SwingConstants.LEFT);
		btnHistorique.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.page.copy.png")));
		btnHistorique.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnHistorique.setBackground(Color.WHITE);
		btnHistorique.setBounds(564, 38, 220, 60);
		contentPanel.add(btnHistorique);
		
		JButton btnClientele = new JButton("Clients");
		btnClientele.setMnemonic('c');
		btnClientele.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new ClientUI(MAinWindow.this);
			}
		});
		btnClientele.setHorizontalAlignment(SwingConstants.LEFT);
		btnClientele.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.group.png")));
		btnClientele.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnClientele.setBackground(Color.WHITE);
		btnClientele.setBounds(564, 142, 220, 60);
		contentPanel.add(btnClientele);
		
		JButton btnEtats = new JButton("Etats");
		btnEtats.setMnemonic('t');
		btnEtats.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnEtats.setIcon(new ImageIcon(MAinWindow.class.getResource("/com/cm/stock/manager/ui/image/appbar.printer.text.png")));
		btnEtats.setHorizontalAlignment(SwingConstants.LEFT);
		btnEtats.setFont(new Font("Segoe UI", Font.PLAIN, 14));
		btnEtats.setBackground(Color.WHITE);
		btnEtats.setBounds(564, 269, 220, 60);
		contentPanel.add(btnEtats);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
	}
}
